PROJECT = lz4
PROJECT_DESCRIPTION = An LZ4 compression library that wraps an NIF
PROJECT_VERSION = 0.2.0

BUILD_DEPS = lz4_src nif_helpers
dep_lz4_src = git https://github.com/lz4/lz4 v1.9.2
dep_nif_helpers = git https://github.com/ninenines/nif_helpers ead6adc15fca3c314351523080d2ccb1956d5956
DEP_PLUGINS = nif_helpers

DEPS = host_triple
dep_host_triple = git https://github.com/rabbitmq/host_triple.git master

C_SRC_OUTPUT = $(CURDIR)/priv/lz4_nif

TEST_DEPS = ct_helper
dep_ct_helper = git https://github.com/extend/ct_helper master

include erlang.mk

CFLAGS += -I $(DEPS_DIR)/lz4_src/lib
# This is required in order to build a liblz4.a that we can
# include in our shared library.
export CPPFLAGS += -shared -fPIC
LDLIBS += $(DEPS_DIR)/lz4_src/lib/liblz4.a

-include c_src/env.mk

cppcheck:
	cppcheck -f --quiet --error-exitcode=2 --enable=all --inconclusive --std=posix \
        -Ideps/lz4_src/lib/ -Ideps/nif_helpers/ -I$(ERTS_INCLUDE_DIR) c_src/

scan-build:
	make clean
	scan-build make

# Download a large file for use in compression tests.

PDF_REFERENCE = https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf

test-build:: $(TEST_DIR)/lz4f_SUITE_data/pdf_reference_1-7.pdf

$(TEST_DIR)/lz4f_SUITE_data/pdf_reference_1-7.pdf:
	$(verbose) mkdir -p $(TEST_DIR)/lz4f_SUITE_data/
	$(gen_verbose) $(call core_http_get,$@,$(PDF_REFERENCE))
